clear; clc;
dataset = 'movielen100k';
load(strcat('../noncvx-lowrank/data/recsys/', dataset, '.mat'));

[row, col, val] = find(data);
idx = randperm(length(val));

traIdx = idx(1:floor(length(val)*0.5));
tstIdx = idx(ceil(length(val)*0.5): end);

clear idx;

traData = sparse(row(traIdx), col(traIdx), val(traIdx));
traData(size(data,1), size(data,2)) = 0;

lambdaMax = 60000;
gradLambda = lambdaMax*(0.75).^(1:10);

para.maxIter = 50000;
para.tol = 1e-3;
para.row = row(tstIdx);
para.col = col(tstIdx);

% start testing
RMSE = zeros(size(gradLambda));
for g = 1:length(gradLambda)
    lambda = gradLambda(g); 

    [P] = FrankWolfe(traData, lambda, para );

    RMSE(g) = sqrt(sum((P - val(tstIdx)).^2)/numel(P));
    clear P temp;
end

lambda = 5.3556e+03;
t = tic;
[P, out] = FrankWolfe(traData, lambda, para );
Time = toc(t);
RMSE = sqrt(sum((P - val(tstIdx)).^2)/numel(P));




  
